package com.deepclassifieds.daas.common;

/**
 * Very basic argument validation static helper methods.
 * @author nbarkhatov
 * @since 1.0
 */
public final class Reject {

	private Reject() {
	}
	
	public static void ifFalse(boolean value) {
		ifFalse(value, "expression must be true");
	}
	
	public static void ifFalse(boolean value, String message) {
		if(!value) {
            throw new IllegalArgumentException(message);
		}
	}

	public static void ifNull(Object obj) {
		if(obj == null) {
            throw new IllegalArgumentException("null not allowed");
		}
	}

	public static void ifNegative(int value) {
		if(value < 0) {
            throw new IllegalArgumentException("cannot be negative number");
		}
	}

	public static void ifNull(Object obj, String message) {
		if(obj == null) {
            throw new IllegalArgumentException("null not allowed: " + message);
		}
	}

	public static void ifNullOrEmpty(String str) {
		if(str == null || str.isEmpty()) {
            throw new IllegalArgumentException("string cannot be null or empty");
		}
	}
}
